package com.lrkj.phone.controller;

import com.lrkj.common.annotation.Log;
import com.lrkj.common.core.controller.BaseController;
import com.lrkj.common.core.domain.AjaxResult;
import com.lrkj.common.core.page.TableDataInfo;
import com.lrkj.common.enums.BusinessType;
import com.lrkj.common.utils.poi.ExcelUtil;
import com.lrkj.phone.domain.AppUser;
import com.lrkj.phone.service.IAppUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * app用户Controller
 *
 * @author yajun_ren
 * @date 2021-04-09
 */
@RestController
@RequestMapping("/appUser")
public class AppUserController extends BaseController {
    @Autowired
    private IAppUserService appUserService;

    /**
     * 查询app用户列表
     */
    @GetMapping("/list")
    public TableDataInfo list(AppUser appUser) {
        startPage();
        List<AppUser> list = appUserService.selectAppUserList(appUser);
        return getDataTable(list);
    }

    /**
     * 导出app用户列表
     */
    @Log(title = "app用户", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(AppUser appUser) {
        List<AppUser> list = appUserService.selectAppUserList(appUser);
        ExcelUtil<AppUser> util = new ExcelUtil<AppUser>(AppUser.class);
        return util.exportExcel(list, "appUser");
    }

    /**
     * 获取app用户详细信息
     */
    @GetMapping(value = "/{appUserId}")
    public AjaxResult getInfo(@PathVariable("appUserId") String appUserId) {
        return AjaxResult.success(appUserService.selectAppUserById(appUserId));
    }

}
